package com.tbit.main.service.impl;

import com.tbit.main.pojo.Host;
import com.tbit.main.pojo.HostList;
import com.tbit.main.service.HostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LMY
 * @create 2022-09-16 14:44
 */
@Service
public class HostServiceImpl implements HostService {

    @Autowired
    private HostList hostList;

    @Override
    public Host getHost(String name) {
        List<Host> hosts = hostList.getHostList();
        Map<String, Host> map = new HashMap<>();
        for (Host host : hosts) {
            map.put(host.getName(), host);
        }
        return map.get(name);
    }
}
